-#
-# Copyright (C) 2013 Google Inc., authors, and contributors <see AUTHORS file>
-# Licensed under http://www.apache.org/licenses/LICENSE-2.0 <see LICENSE file>
-# Created By:
-# Maintained By:
-#
-extends "layouts/dashboard.haml"

-set model = controller.model
-set model_name = controller.model_name
-set model_title = model_name|title

-block title
  =instance.title

-block page_help
  =model_name

-block extra_javascript
  GGRC.page_object = ={ instance_json()|safe };

-block header
  %ul.breadcrumbs
    %li=link_to 'dashboard', dashboard_path
    %li=instance.slug

  %h1.business
    .grcobject.business{ 'rel': "tooltip", 'data-placement': "bottom", 'title': "#{model_title}" }
      -if model_title == "Org Group"
        %i.grcicon-orggroup
      -elif model_title == "Market"
        %i.grcicon-market
      -elif model_title == "Facility"
        %i.grcicon-facility
      -elif model_title == "Project"
        %i.grcicon-project
      -elif model_title == "Data Asset"
        %i.grcicon-dataasset
      -else
        &nbsp;
    =instance.title

-block subheader_extras
  %ul.actions.pull-right
    %li
      %a{ 'href': "url-for-edit-#{model_name}-#{instance.id}", 'data-toggle': 'modal-ajax-form', 'data-modal-reset': 'reset', 'data-form-target': 'refresh', 'data-modal-class': 'modal-wide', 'title': "Edit #{model_title}" }
        %i.grcicon-edit
        %span Edit #{model_title}

-block subheader_plus
  %a.navbarplus.fltrt{ 'href': "url-for-new-#{model_name}", 'data-toggle': 'modal-ajax-form', 'data-modal-reset': 'reset', 'data-form-target': 'redirect', 'data-modal-class': 'modal-wide'}

-block main
  .container-fluid
    #show_columns.row-fluid{ 'data-resize': "true" }
      #middle_column.span8.widget-area
        -# FIXME: Make a good pattern for lookup paths
        -#   e.g. 'programs/_main.haml', 'programs/_main.html', 'base_objects/_main.haml', ...
        -#   perhaps traverse MRO, then 'shared/'
        -with widget_class = 'business'
          -#include lookup("main", instance)
        -#if instance|has_valid_relationships
          -with widget_class = 'widget-tabs widget-tabs-horizontal business'
            -#include lookup('related')
          -#include lookup('add_widget_section')

      #right_column.span4.widget-area
        -with widget_class = 'business'
          -#include lookup('info')
          -#include lookup('more_info')
        -#if instance|has_valid_relationships
          -#include lookup('add_widget_section')
